<?php
	/**
	* connect to your database with mySQL
	*/
	
	class con_db
	{
		var $conn;
		function __construct()
		{
			$servername = "localhost";
			$username = "user";
			$password = "id";
			$dbname = "my_db";
			$this->conn = new mysqli($servername, $username, $password, $dbname);
			// Check connection
			if ($this->conn->connect_error) {
				die("Could not connect: " . $this->conn->connect_error);
			} 
		}

		public function query($sql)
		{
			$result = $this->conn->query($sql);
			if (!$result)
			{
				if(mysqli_errno($this->conn)=="1064"){
					die("字长超过限制200");
				}
				die('Error: ' . mysqli_errno($this->conn));
			}
			return $result;
		}

		function __distruct()
		{
			$this->conn->close();
		}
	}
?>